USE [FootballPoll]
GO

/****** Object:  StoredProcedure [dbo].[GetAllVoteDatesByUserName]    Script Date: 12/02/2011 13:27:14 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GetAllVoteDatesByUserName]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[GetAllVoteDatesByUserName]
GO

USE [FootballPoll]
GO

/****** Object:  StoredProcedure [dbo].[GetAllVoteDatesByUserName]    Script Date: 12/02/2011 13:27:14 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO


CREATE PROCEDURE [dbo].[GetAllVoteDatesByUserName] 
	/****** Pass in parameters  ******/ 
		@UserName VARCHAR(255) 
AS 
	/****** Explicit declaration for testing  ******/ 
	/* 
		DECLARE @UserName VARCHAR(255)  
		SET @UserName = 'gonzo'  
	*/ 
	/****** Explicit declaration for testing  ******/ 
  SELECT v.userid, 
         v.DATE, 
         v.votesourceid 
  FROM   votes v 
         LEFT JOIN users u 
           ON u.id = v.userid 
              AND u.username = @UserName 
  WHERE  v.userid = u.id 
  GROUP  BY v.userid, 
            v.DATE, 
            v.votesourceid 


GO

